package com.cyf.plc.util

import android.app.ActivityManager
import android.content.Context
import android.os.Process

object AppUtils {
    fun getCurrentProcessName(context: Context): String? {
        val pid = Process.myPid()
        val mActivityManager = context
            .getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
        for (appProcess in mActivityManager.runningAppProcesses) {
            if (appProcess.pid == pid) {
                return appProcess.processName
            }
        }
        return null
    }
}